package com.itheima.servlet;

import com.itheima.dao.Userdao;
import com.itheima.dao.UserdaoImpl;
import com.itheima.domain.User;

public class UserServletImpl implements UserServlet {
    Userdao userdao = new UserdaoImpl();

    @Override
    public boolean register(User user) {
        int add = userdao.add(user);
        if (add == 1) {
            return true;
        }
        return false;
    }

    //如果返回值是true那么就表示用户名可用，否则反之
    @Override
    public boolean isnewusername(String username) {
        User findusername = userdao.findusername(username);
        if (findusername == null) {
            return true;
        }
        return false;
    }

    @Override
    public boolean login(User user) {
        User findusernamepassword = userdao.findusernamepassword(user.getUsername(), user.getPassword());
        if (findusernamepassword != null) {
            return true;
        }
        return false;
    }
}